<nz-card class="m-b-2">
  <div class="common-search-wrap">
    <div class="common-search-forms">
      <div class="common-form-item">
        <label class="common-search-label">标题</label>
        <div class="common-search-conrol">
          <input nz-input placeholder="请输入标题" [(ngModel)]="seachParams.activityName" />
        </div>
      </div>

      <div class="common-form-item">
        <label class="common-search-label">状态</label>
        <div class="common-search-conrol">
          <nz-select nzShowSearch nzAllowClear nzPlaceHolder="请选择状态" [(ngModel)]="seachParams.status">
            <nz-option nzLabel="未开始" nzValue="0"></nz-option>
            <nz-option nzLabel="进行中" nzValue="1"></nz-option>
            <nz-option nzLabel="已删除" nzValue="2"></nz-option>
            <nz-option nzLabel="已结束" nzValue="3"></nz-option>
            <nz-option nzLabel="禁用" nzValue="4"></nz-option>
          </nz-select>
        </div>
      </div>

      <div class="common-form-item">
        <div class="common-search-conrol">
          <button nz-button nzType="primary" class="m-r-8" [nzLoading]="tableParams.tableLoading" (click)="seachData()">查询</button>
          <button nz-button nzType="default" (click)="resetData()">重置</button>
        </div>
      </div>
    </div>
  </div>
</nz-card>

<nz-card>
  <nz-space class="p-b-10">
    <button *nzSpaceItem nz-button nzType="primary" (click)="jumpPage(0)">新增配置</button>
    <button *nzSpaceItem nz-button nzType="primary" (click)="jumpPage(3)">抽奖记录</button>
  </nz-space>

  <!-- Table -->
  <div class="pagination-wrap-position">
    <div class="table-wrap">
      <nz-table
        #basicTable
        nzSize="small"
        nzShowSizeChanger
        nzShowQuickJumper
        nzOuterBordered
        [nzScroll]="{ x: '1100px' }"
        [nzFrontPagination]="false"
        [nzLoadingDelay]="100"
        [nzLoading]="tableParams.tableLoading"
        [nzData]="tableData"
        [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
        [nzTotal]="tableParams.total"
        [nzPageIndex]="tableParams.page"
        [nzPageSize]="tableParams.pageSize"
        [nzShowTotal]="totalTemplate"
        (nzPageIndexChange)="onPageIndexChange($event)"
        (nzPageSizeChange)="onPageSizeChange($event)"
      >
        <thead>
          <tr>
            <th nzAlign="center" nzWidth="120px" nzLeft>ID</th>
            <th nzAlign="center" nzWidth="220px">名称</th>
            <th nzAlign="center" nzWidth="130px">状态</th>
            <th nzAlign="center" nzWidth="130px">适用用户</th>
            <th nzAlign="center" nzWidth="120px">剩余总量</th>
            <th nzAlign="center" nzWidth="200px">订单门槛</th>
            <th nzAlign="center" nzWidth="200px">生效开始时间</th>
            <th nzAlign="center" nzWidth="200px">生效截至时间</th>
            <th nzAlign="center" nzWidth="250px">备注</th>
            <th nzAlign="center" nzWidth="300px" nzRight>操作</th>
          </tr>
        </thead>

        <tbody>
          <tr *ngFor="let data of basicTable.data; let index = index;">
            <!-- ID -->
            <td nzAlign="center" nzLeft>{{ data.id }}</td>
            <!-- 名称 -->
            <td nzAlign="center">{{ data.activityName || '-' }}</td>
            <!-- 状态 -->
            <td nzAlign="center">
              <span [ngStyle]="{'color': data.status | placeStatus: 'color'}">
                {{ data.status | placeStatus: 'text' }}
              </span>
            </td>
            <!-- 适用用户 -->
            <td nzAlign="center">
              <ng-container [ngSwitch]="data.userType">
                <nz-tag *ngSwitchCase="'0'">通用</nz-tag>
                <nz-tag *ngSwitchCase="'2'" [nzColor]="'#2db7f5'">B端</nz-tag>
                <nz-tag *ngSwitchCase="'1'" [nzColor]="'#87d068'">C端</nz-tag>
                <div *ngSwitchDefault>-</div>
              </ng-container>
            </td>
            <!-- 剩余总量 -->
            <td nzAlign="center">{{ data.surplusTotal || '0' }}</td>
            <!-- 订单门槛 -->
            <td nzAlign="center">{{ data.orderPrice || '-' }}</td>
            <!-- 生效开始时间 -->
            <td nzAlign="center">{{ data.beginTime || '-' }}</td>
            <!-- 生效截至时间 -->
            <td nzAlign="center">{{ data.endTime || '-' }}</td>
            <!-- 备注 -->
            <td nzAlign="center">{{ data.bak || '-' }}</td>
            <!-- 操作 -->
            <td nzAlign="center" nzRight>
              <button nz-button nzType="link" (click)="jumpPage(2, data)">复制</button>
              <button nz-button nzType="link" (click)="jumpPage(1, data)">编辑</button>
              <a
                *ngIf="data.status == 4"
                nz-button
                nzType="link"
                nz-popconfirm
                nzPopconfirmTitle="确认启用?"
                [nzIcon]="iconTpl"
                (nzOnConfirm)="enableDisable(data, 0)">
                启用
              </a>
              <ng-template #iconTpl>
                <i nz-icon nzType="question-circle-o" style="color: red;"></i>
              </ng-template>
              <a
                *ngIf="data.status != 4"
                nz-button
                nzType="link"
                nzDanger=""
                nz-popconfirm
                nzPopconfirmTitle="确认禁用?"
                [nzIcon]="iconTpl"
                (nzOnConfirm)="enableDisable(data, 4)">
                禁用
              </a>
              <ng-template #iconTpl>
                <i nz-icon nzType="question-circle-o" style="color: red;"></i>
              </ng-template>
            </td>
          </tr>
        </tbody>
      </nz-table>

      <!-- 分页template -->
      <ng-template #totalTemplate let-total>共有 {{ tableParams.total }} 条</ng-template>
    </div>
  </div>
</nz-card>